package com.firewolf.springboot.controller;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.firewolf.springboot.dao.DepartmentDao;
import com.firewolf.springboot.entities.Department;
import com.github.pagehelper.PageHelper;

@RestController
public class DeptController {

	@Autowired
	private DepartmentDao dao;
	
	@RequestMapping("/all")
	public List<Department> findAll(){
		//分页参数：
		//参数1 ： 第几页
		//参数2 ： 一页几个
		PageHelper.startPage(3, 2);
		return dao.findAllDepts();
	}
	
	@RequestMapping("/id/{id}")
	public Department findById(@PathVariable("id") Integer id){
		return dao.fidById(id);
	}
}
